#include "ServerTimeMgr.h"
#include <core/time/system_time.h>

ServerTimeMgr& ServerTimeMgr::instance()
{
	static ServerTimeMgr s_tm;
	return s_tm;
}

time_t ServerTimeMgr::serverTime()
{
	return time(0) - m_time_delta;
}

void ServerTimeMgr::setServerTime(const time_t& serverTime)
{
	m_time_delta = time(0) - serverTime;
	bool bDayChange = false;
	qb::base::CTime ctCur(serverTime);
	qb::base::CTime ctPrev(m_prev_time);
	if (ctCur.GetYear() != ctPrev.GetYear() || ctCur.GetMonth() != ctPrev.GetMonth() || ctCur.GetDay() != ctPrev.GetDay())
		bDayChange = true;

	m_prev_time = serverTime;
}
